<?php

/**
 * default actions.
 *
 * @package    vmdai
 * @subpackage default
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class defaultActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
//    $this->forward('default', 'module');
  }
  
  public function executeLogin(sfWebRequest $request){
      if($request->isMethod('POST')){
	  $user_name = trim($request->getParameter('user_name',''));
	  $password = trim($request->getParameter('password',''));
	  $user_name_system = sfConfig::get('app_admin_username');
	  $password_system = sfConfig::get('app_admin_password');
	  
	  if($user_name == $user_name_system && md5($password) == md5($password_system)){
	      $this->getUser()->setAuthenticated(true);
	  }else{
	      $this->getUser()->setFlash('error', '用户名密码错误！');
	      $this->redirect('default/login');
	  }
	  $this->redirect('@homepage');
      }
  }
  
  public function executeLogout(sfWebRequest $request){
	      $this->getUser()->setAuthenticated(false);
	      $this->redirect('default/login');
  }
  
}
